package socketmvc.core.packets;

import socketmvc.core.packets.basic.IPacket;
import socketmvc.core.packets.basic.impl.JsonTextBody;
import socketmvc.core.packets.basic.impl.JsonSimplePacket;

public class ErrorPacket extends JsonSimplePacket {

    public ErrorPacket(String err) {
        this(err,null);
    }

    public ErrorPacket(Exception e) {
        this(e.getMessage());
    }

    public ErrorPacket(Object err,String responseKey) {
        JsonTextBody textBody = new JsonTextBody();
        textBody.setCommand("/@error-response");
        textBody.setBody(err);
        textBody.setResponseKey(responseKey);
        textBody.setResponse(true);
        this.textBody = textBody;
    }

    public ErrorPacket(Exception e, IPacket packet) {
        this(e.getMessage(),packet.getResponseKey());
    }

}
